<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>vue3实现过滤器</title>
  </head>
  <body>
    <div id="app">
      {{ sexShow }} -- {{ priceShow }} -- {{ $priceShow }}
      <hr />
      {{ sexShowFn() }} -- {{ priceShowFn() }} -- {{ $priceShowFn() }}
    </div>
  </body>
  <script src="../lib/vue.global.js"></script>
  <script>
    Vue.createApp({
      data() {
        return {
          sex: 1,
          price: 100,
        };
      },
      computed: {
        sexShow() {
          return this.sex === 1 ? "男" : "女";
        },
        $priceShow() {
          return "$" + this.price;
        },
        priceShow() {
          return "¥" + this.price;
        },
      },
      methods: {
        sexShowFn() {
          return this.sex === 1 ? "男" : "女";
        },
        $priceShowFn() {
          return "$" + this.price;
        },
        priceShowFn() {
          return "¥" + this.price;
        },
      },
    }).mount("#app");
  </script>
</html>
